package IOStreamTest.FileStream;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/*
读取一个文件，并打印到控制台
 */
public class FileInputStreamTest3 {
    public static void main(String[] args){
        FileInputStream fis = null;
        try{
            fis = new FileInputStream("src\\MapTest\\MapTest1.java");
            byte[] bytes = new byte[1024];
            int num = 0;
            while((num = fis.read(bytes)) != -1){
                System.out.println(new String(bytes,0,num));
            }
        }catch(FileNotFoundException f){
            f.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally{
            if (fis != null) {
                try {
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
